<?php 

class Model_Map extends Joob_Db_Table{
	
	public static function getDistance($p1_lat, $p1_lng, $p2_lat, $p2_lng){
        $x1 = deg2rad((float)$p1_lat);
        $y1 = deg2rad((float)$p1_lng);
        $x2 = deg2rad((float)$p2_lat);
        $y2 = deg2rad((float)$p2_lng);
        $a = sin($x1)*sin($x2)+ cos($x1)*cos($x2)*cos($y2-$y1);
        $c = acos($a);
        
        $R = 6371;
        return ($R*$c);
    }
	
}

?>